package com.example.QQ;

import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class SendMessage extends Thread{
    Socket socket;
    String message;
    public SendMessage(String message) {
        this.message = message;
    }
    public void run() {
        try {
            ServerSocket server = new ServerSocket(7400);
         Socket socket = server.accept();
        OutputStream os = socket.getOutputStream();
        System.out.println(message);
        //使用网络字节输出流OutputStream对象中的方法write,给客户端回写数据
        os.write(message.getBytes());
        } catch (IOException e) {
        e.printStackTrace();
    }
    }
}
